package com.spic.system.activiti.controller;


import com.spic.common.core.domain.R;
import com.spic.common.core.web.controller.BaseController;
import com.spic.system.activiti.domain.BusinessStatus;
import com.spic.system.activiti.service.IBusinessStatusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/status")
public class StateController extends BaseController {
    @Autowired
    private IBusinessStatusService iBusinessStatusService;

    //获取流程状态
    @GetMapping(value = "/list")
    public List<BusinessStatus> getStatus(BusinessStatus businessStatus) {
            List<BusinessStatus> status = iBusinessStatusService.selectBusinessStatusList(businessStatus);
            return status;
        }
    @GetMapping("/list/selectStateBybusinessType")
    public R<List<BusinessStatus>> getStateByBusinessType(@RequestParam("businessType") String businessType) {
        List<BusinessStatus> businessStatuses = iBusinessStatusService.selectStatusByType(businessType);
        return R.ok(businessStatuses);
    }

    @PostMapping("/list/selectStateByTypeAndKeys/{businessType}")
    public R<List<BusinessStatus>> getStateByBusinessType(@PathVariable("businessType") String  businessType , @RequestBody List<String> keys) {
        List<BusinessStatus> businessStatuses = iBusinessStatusService.selectStatus(businessType, keys);
        return R.ok(businessStatuses);
    }
}
